x86/mm/p2m: don't overwrite m2p entry of still-shared pages
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 24 Nov 2011 15:20:57 +0000 (15:20 +0000)
committerAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 24 Nov 2011 15:20:57 +0000 (15:20 +0000)
When updating a p2m mapping to shared, previous code
unconditionally set the m2p entry for the old mfn to invalid.
We now check that the old mfn does not remain shared.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/p2m.c

index 51a0096e6c6a4117b8d3d2ae2b4a7e12edee9c3e..f33b7736183bd7fb6c0dff339925fc8498e99489 100644 (file)
@@ -714,8 +714,9 @@ set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn)
      * sharable first */
     ASSERT(p2m_is_shared(ot));
     ASSERT(mfn_valid(omfn));
-    /* XXX: M2P translations have to be handled properly for shared pages */
-    set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
+    if ( ((mfn_to_page(omfn)->u.inuse.type_info & PGT_type_mask) 
+                    != PGT_shared_page) )
+        set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
 
     P2M_DEBUG("set shared %lx %lx\n", gfn, mfn_x(mfn));
     rc = set_p2m_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_shared, p2m->default_access);